package com.example.mvp.adapter

import android.content.Context
import android.view.View
import com.example.baselibrary.R
import com.example.inter.ItemClickInterface
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.binder.DataBinder
import com.example.mvp.delegate.UPImageDelegate

/**
 * 上传图片
 * @author  chaohaipeng  on 2018/8/9.
 */
class UPImageAdapter (context: Context, mlist: List<String>,num:Int,itemClickInterface: ItemClickInterface) :BaseUpImageAdapter<UPImageDelegate,String>(context,mlist,num) {
    /**
     * 数据
     */
    val mList = mlist
    /**
     * 上下文
     */
    val mContext = context

    val mItemClickInterface=itemClickInterface

    override fun bindEvenListener(viewDelegate: UPImageDelegate?, position: Int) {
        viewDelegate?.setOnClickListener(View.OnClickListener {
            mItemClickInterface?.itemClick(position)
        }, R.id.iv_up_delete_btn)


    }

    override fun notifyView(viewDelegate: UPImageDelegate?, position: Int) {
        if (position== mList.size) {
            viewDelegate?.initDataView(mContext)
        }else{
            viewDelegate?.initData(mContext,mList.get(position))
        }
    }

    override fun getDelegateClass(): Class<UPImageDelegate> {
        return UPImageDelegate::class.java
    }

    override fun getDataBinder(): BaseDataBinder<*, *> {
        return DataBinder()
    }
}